package com.wutuo.wtservice.provider.dao;

import cn.apestar.core.base.GenericMapper;
import cn.apestar.core.base.MapperAnnotation;
import com.wutuo.wtservice.provider.domain.WtService;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

/**
 * 服务关系表 Dao 层
 *
 * @author lvh
 * @version 1.0
 */

@MapperAnnotation public interface BaseServiceMapper extends GenericMapper<WtService, Long> {

    @Override @Delete({"delete from service", "where id = #{id,jdbcType=BIGINT}"})
    int deleteByPrimaryKey(Long id);

    @Override @Insert({"insert into service (", "name,", "start_tiem,", "end_time,", "type,",
        "cm_institution_id,", "create_by,", "create_date,", "update_by,", "update_date,",
        "remarks,", "del_flag", " )values(", "#{name,jdbcType=VARCHAR},",
        "#{startTiem,jdbcType=DATE},", "#{endTime,jdbcType=DATE},", "#{type,jdbcType=BIGINT},",
        "#{cmInstitutionId,jdbcType=BIGINT},", "#{createBy,jdbcType=BIGINT},",
        "#{createDate,jdbcType=DATE},", "#{updateBy,jdbcType=BIGINT},",
        "#{updateDate,jdbcType=DATE},", "#{remarks,jdbcType=VARCHAR},",
        "#{delFlag,jdbcType=VARCHAR})"}) int insert(WtService record);

    @InsertProvider(type = BaseServiceSqlProvider.class, method = "insertSelective")
    int insertSelective(WtService record);

    @Override @Select({"select", "name,", "start_tiem,", "end_time,", "type,", "cm_institution_id,",
        "create_by,", "create_date,", "update_by,", "update_date,", "remarks,", "del_flag",
        "from service", "where id = #{id,jdbcType=BIGINT}"})
    @Results({@Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
        @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR),
        @Result(column = "start_tiem", property = "startTiem", jdbcType = JdbcType.DATE),
        @Result(column = "end_time", property = "endTime", jdbcType = JdbcType.DATE),
        @Result(column = "type", property = "type", jdbcType = JdbcType.BIGINT),
        @Result(column = "cm_institution_id", property = "cmInstitutionId", jdbcType = JdbcType.BIGINT),
        @Result(column = "create_by", property = "createBy", jdbcType = JdbcType.BIGINT),
        @Result(column = "create_date", property = "createDate", jdbcType = JdbcType.DATE),
        @Result(column = "update_by", property = "updateBy", jdbcType = JdbcType.BIGINT),
        @Result(column = "update_date", property = "updateDate", jdbcType = JdbcType.DATE),
        @Result(column = "remarks", property = "remarks", jdbcType = JdbcType.VARCHAR),
        @Result(column = "del_flag", property = "delFlag", jdbcType = JdbcType.VARCHAR)})
    WtService selectByPrimaryKey(Long id);

    @Override
    @UpdateProvider(type = BaseServiceSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(WtService record);

    @Override @Update({"update service", "set ", "name = #{name,jdbcType=VARCHAR},",
        "start_tiem = #{startTiem,jdbcType=DATE},", "end_time = #{endTime,jdbcType=DATE},",
        "type = #{type,jdbcType=BIGINT},",
        "cm_institution_id = #{cmInstitutionId,jdbcType=BIGINT},",
        "create_by = #{createBy,jdbcType=BIGINT},", "create_date = #{createDate,jdbcType=DATE},",
        "update_by = #{updateBy,jdbcType=BIGINT},", "update_date = #{updateDate,jdbcType=DATE},",
        "remarks = #{remarks,jdbcType=VARCHAR},", "del_flag = #{delFlag,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=BIGINT}"}) int updateByPrimaryKey(WtService record);
}